package cn.convert.action;

import java.util.regex.Pattern;

public class LoginAction extends BaseAction{
	private String username;
	private String userpass;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getUserpass() {
		return userpass;
	}
	public void setUserpass(String userpass) {
		this.userpass = userpass;
	}
	public void validate(){
		if ("".equals(username)) {
			addFieldError("username", "用户名不能为空");
		}else if(!Pattern.matches("\\w{5,8}",username.trim())){
			addFieldError("username", "用户名必须有5至8位数字与英文字母组成");
		}
		
		if ("".equals(userpass)) {
            addFieldError("userpass", "密码不能为空");			
		}else if (!Pattern.matches("\\w{6,10}",userpass.trim())) {
			addFieldError("userpass", "密码必须有6至10位数字与英文字母组成");
		}
	}
	public String execute(){
		System.out.println("正在执行execute方法.........");
		return SUCCESS;
	}
	

}
